package ui.other;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;

import javax.swing.border.Border;

public class YPBorderFactory {
	public static Border getUnderLineBorder() {
		return new UnderLineBorder();
	}

	public static Border getUnderLineBorder(Color c) {
		return new UnderLineBorder(c);
	}
	
	public static Border getRightOpenBorder() {
		return new RightOpenBorder();
	}
	public static Border getLeftOpenBorder() {
		return new LeftOpenBorder();
	}

}

class RightOpenBorder implements Border {

    @Override
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        int x1 = x + width, y1 = y, x2 = x, y2 = y + height - 1, x3 = x + width, y3 = y + height - 1;
        g.drawLine(x, y, x2, y2);
        g.drawLine(x, y, x1, y1);
        g.drawLine(x2, y2, x3, y3);
    }

    @Override
    public Insets getBorderInsets(Component c) {
        return new Insets(1, 1, 1, 1);
    }

    @Override
    public boolean isBorderOpaque() {
        return false;
    }

}
class LeftOpenBorder implements Border{
	@Override
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
		int x1 = x + width, y1 = y, x2 = x, y2 = y + height - 1, x3 = x + width, y3 = y + height - 1;
        g.drawLine(x1, y1, x3, y3);
        g.drawLine(x, y, x1, y1);
        g.drawLine(x2, y2, x3, y3);
    }

    @Override
    public Insets getBorderInsets(Component c) {
        return new Insets(1, 1, 1, 1);
    }

    @Override
    public boolean isBorderOpaque() {
        return false;
    }
}

class UnderLineBorder implements Border {

	private Color color;

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	public UnderLineBorder() {
		color = Color.GRAY;
	}

	public UnderLineBorder(Color c) {
		color = c;
	}

	@Override
	public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
		g.setColor(color);
		g.drawLine(x, y + height - 1, x + width, y + height - 1);
	}

	@Override
	public Insets getBorderInsets(Component c) {
		return new Insets(1, 1, 1, 1);
	}

	@Override
	public boolean isBorderOpaque() {
		return false;
	}
}